Namespace Core.Modules

    Public Class ProductImageData

        Private _bvin As String = String.Empty
        Private _FileName As String = String.Empty
        Private _Caption As String = String.Empty
        Private _AlternateText As String = String.Empty
        Private _ProductId As String = String.Empty
        Private _SortOrder As Integer = 0

        Public Property Bvin() As String
            Get
                Return _bvin
            End Get
            Set(ByVal value As String)
                _bvin = value
            End Set
        End Property
        Public Property FileName() As String
            Get
                Return _FileName
            End Get
            Set(ByVal value As String)
                _FileName = value
            End Set
        End Property
        Public Property Caption() As String
            Get
                Return _Caption
            End Get
            Set(ByVal value As String)
                _Caption = value
            End Set
        End Property
        Public Property AlternateText() As String
            Get
                Return _AlternateText
            End Get
            Set(ByVal value As String)
                _AlternateText = value
            End Set
        End Property
        Public Property ProductId() As String
            Get
                Return _ProductId
            End Get
            Set(ByVal value As String)
                _ProductId = value
            End Set
        End Property
        Public Property SortOrder() As Integer
            Get
                Return _SortOrder
            End Get
            Set(ByVal value As Integer)
                _SortOrder = value
            End Set
        End Property

        Public Sub New()

        End Sub

        Public Sub New(ByVal img As BVweb.ProductImage)
            If img IsNot Nothing Then
                _bvin = img.Bvin
                _FileName = img.FileName
                _Caption = img.Caption
                _AlternateText = img.AlternateText
                _ProductId = img.ProductId
                _SortOrder = img.SortOrder
            End If
        End Sub

        Public Overrides Function ToString() As String
            Dim result As String = String.Empty

            result = result & Bvin & "^" & FileName & "^" & AlternateText & "^" & Caption

            Return result
        End Function

        Public Sub FromString(ByVal input As String)
            Dim parts() As String = input.Split("^")
            If parts IsNot Nothing Then
                If parts.Length > 0 Then
                    Bvin = MapperUtils.ParseFieldString(parts(0), String.Empty)
                    If Bvin.Trim.ToLower = "new" Then
                        Bvin = String.Empty
                    End If
                End If
                If parts.Length > 1 Then
                    FileName = MapperUtils.ParseFieldString(parts(1), String.Empty)
                End If
                If parts.Length > 2 Then
                    AlternateText = MapperUtils.ParseFieldString(parts(2), String.Empty)
                End If
                If parts.Length > 3 Then
                    Caption = MapperUtils.ParseFieldString(parts(3), String.Empty)
                End If
            End If
        End Sub

        Public Function ToImage() As BVweb.ProductImage
            Dim result As New BVweb.ProductImage
            result.AlternateText = Me.AlternateText
            result.Bvin = Me.Bvin
            result.Caption = Me.Caption
            result.FileName = Me.FileName
            result.ProductId = Me.ProductId
            result.SortOrder = Me.SortOrder
            Return result
        End Function

    End Class

End Namespace